/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-06-23     RT-Thread    first version
 */

#include <rtthread.h>
#include "head.h"

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

rt_thread_t thread_1;

rt_mutex_t vl53l0_mutex;

int main(void)
{
    vl53l0x_init(&vl53l0x_dev);     //vl53l0初始化
    rt_thread_mdelay(1000);
    /*--------------------VL53L0线程部分------------------------------*/
    thread_1 = rt_thread_create("vl53l0",
                                 vl53l0_thread, RT_NULL,
                                 1024, 20, 50);
    if(thread_1 != RT_NULL)
        rt_thread_startup(thread_1);
    //创建锁
    vl53l0_mutex = rt_mutex_create("tof_mute", RT_IPC_FLAG_PRIO);
    if(vl53l0_mutex != RT_NULL)
        rt_kprintf("create tof mutex sucess ...\n");
    /*----------------------------------------------------*/

    return RT_EOK;
}

//VL53L0线程
void vl53l0_thread(void *parameter)
{
    while(1)
    {
        vl53l0x_general_start(&vl53l0x_dev,Default_Mode);
        rt_thread_mdelay(100);
    }
}
